import java.util.Stack;

public class homework1 {

    public int evalRPN(String[] tokens) {
        Stack<Integer> strack=new Stack<>();
        int temp,temp1;
        for (String s:tokens){
            if(s.equals("+")||s.equals("-")||s.equals("*")||s.equals("/")){
                switch (s){
                    case "+":
                        temp1=strack.pop();
                        temp=strack.pop();
                        strack.push(temp+temp1);
                        break;
                    case "-":
                        temp1=strack.pop();
                        temp=strack.pop();
                        strack.push(temp-temp1);
                        break;
                    case "*":
                        temp1=strack.pop();
                        temp=strack.pop();
                        strack.push(temp*temp1);break;
                    case "/":
                        temp1=strack.pop();
                        temp=strack.pop();
                        strack.push(temp/temp1);
                        break;
                }
            }
            else{
                Integer ret=Integer.valueOf(s);
                strack.push(ret);
            }
        }
        return strack.peek();
    }
}
